package com.energy.analysis.sys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.energy.analysis.comm.base.BaseMapper;
import com.energy.analysis.comm.base.BaseService;
import com.energy.analysis.sys.entity.Department;
import com.energy.analysis.sys.entity.OprInfo;
import com.energy.analysis.sys.mapper.DepartmentMapper;

@Service
public class DepartmentService extends BaseService<Department> {

	@Autowired
	private DepartmentMapper departmentMapper;


	@Override
	protected BaseMapper<Department> getMapper() {
		return departmentMapper;
	}
	
	/**
	 * 搜索部门
	 */
//	public List<Department> searchDept(String depName)
//			throws Exception {
//		List<Department> list = departmentMapper.searchDept(depName);
//		return list;
//	}
	
	/**
	 * 根据ID 查询
	 */
	public Department findDepId(Integer depId) throws Exception{
		Department department =departmentMapper.findDepId(depId);
		return department;
	}

	/**
	 * 验证部门名称
	 */
	public int existDepName(String depName) throws Exception {
		int dept = departmentMapper.existDepName(depName);
		return dept;
	}
	
	/**
	 * 添加部门
	 */
	public int insertDept(Department department) throws Exception {
		int dept = departmentMapper.insertDept(department);
		return dept;
	}
	
	/**
	 * 修改部门
	 */
	public int updateDept(Department department) throws Exception {
		int dept = departmentMapper.updateDept(department);
		return dept;
	}

	/**
	 *删除部门
	 */
	public Integer deleteDept(Integer depId) throws Exception {
		int dept = departmentMapper.deleteDept(depId);
		return dept;
	}

	/**
	 *部门详情
	 */
	public List<OprInfo> detailDepId(Integer depId) throws Exception {
		List<OprInfo> list =departmentMapper.detailDepId(depId);
			return list;
	}

	/**
	 *部门操作员校验
	 */
	public int find0prDepId(Integer depId) throws Exception {
		int count = departmentMapper.find0prDepId(depId);
		return count;
	}
}
